const logger = require('../conf/logger');

var socketClient = {

    connect(){
        this.socket = require('socket.io-client')('http://112.74.110.104:8080');
        this.socket.on('connect', function(){
            logger.debug('连接成功');
        });

        this.socket.on('disconnect', function(){
            logger.debug("断开连接成功")
        });

    },

    disconnect(){
        this.socket.disconnect();
    },

    send(body){

        this.socket.emit('new_message', body, function (msg) {
            logger.debug("发送成功:" + JSON.stringify(msg));
        });

    }
};

module.exports.socketClient = socketClient;